using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PrimitiveEngine.Primitives
{
    public enum PEPrimitiveType
    {
        Line,
        Triangle,
        Circle,
        Rectangle,
        Polygon,
        Curve,
        String,
    }
    
    public abstract class PEPrimitive : IComparable<PEPrimitive>
    {
        public Vector2 Position { get; set; }
        public float Rotation { get; set; }
        public Color BorderColor { get; set; }
        public float BorderWidth { get; set; }
        public bool IsFilled { get; set; }
        public Color FillColor { get; set; }
        public float Layer { get; set; }
        public PEPrimitiveType Type { get; protected set; }
        public abstract int PrimitiveCount { get; }

        public static Comparison<PEPrimitive> LayerComparison = delegate(PEPrimitive p1, PEPrimitive p2)
        {
            return p2.Layer.CompareTo(p1.Layer);
        };

        public abstract bool Intersection(PEPrimitive primitive);

        public abstract bool Inside(Vector2 point);

        public abstract void CreateUV();

        public abstract void Draw(ref VertexPositionColorTexture[] vertices, ref int vertexIndex, ref short[] indices, ref int indiceIndex);

        #region IComparable<PEPrimitive> Members

        public int CompareTo(PEPrimitive other)
        {
            return other.Layer.CompareTo(this.Layer);
        }

        #endregion
    }
}
